<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/9/12
  Time: 16:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加业主</title>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-3.1.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery.validate.js"></script>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/roleManagement.css">
    <link id="layuicss-layer" rel="stylesheet" href="file:///C:/Users/Administrator.ITIANKONG/Desktop/cpts_1065_vip-admin/frame/layui/css/modules/layer/default/layer.css?v=3.0.3" media="all"><link id="layuicss-laydate" rel="stylesheet" href="file:///C:/Users/Administrator.ITIANKONG/Desktop/cpts_1065_vip-admin/frame/layui/css/modules/laydate/default/laydate.css?v=5.0.2" media="all">
    <style>
        .showmessages{
            width: 460px;
            margin-top: 80px;
        }
        label.error {
            color: red;
            font-size: 12px;
        }
    </style>
</head>
<body class="body">
<div class="pageall">
    <div class="backphall">
        <div class="titleall">
            <div class="titleph">
                <img src="${pageContext.request.contextPath}/static/images/host1.png" style="width:100%;height:100%;"/>
            </div>
            <div class="titleword">业主管理 >>> 业主添加</div>
        </div>

        <div class="contentall"></div>
    </div>
    <div class="showmessages">
        <form action="hostAddController.do"  method="post" class="layui-form" id="f">
            <div class="layui-form-item">
                <label class="layui-form-label">业主楼栋：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_building" lay-verify="title"  placeholder="请输入业主所在的楼栋（正整数）" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">业主单元：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_unit" lay-verify="required" placeholder="请输入业主所在的单元（正整数）" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">门牌号：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_housenumber" lay-verify="required" placeholder="请输入业主所在的门牌号（正整数）" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_name" lay-verify="required" placeholder="请输入姓名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号码：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_phone" lay-verify="required" placeholder="请输入手机号码（11位数字）" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">住户人数：</label>
                <div class="layui-input-block">
                    <input type="text" name="host_number" lay-verify="required" placeholder="请输入居住的总人数" class="layui-input">
                </div>
            </div>
            <%--<div class="layui-form-item">--%>
                <%--<label class="layui-form-label">创建人：</label>--%>
                <%--<div class="layui-input-block">--%>
                    <%--<input type="text" name="host_create_admin_id" lay-verify="required" placeholder="请输入创建人的编号" class="layui-input">--%>
                <%--</div>--%>
            <%--</div>--%>
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>

        </form>
    </div>
</div>

</body>
<script>
    /*
使用jquery validate限制表单
*/ $.validator.addMethod("wordstyle",function(value,element,params){
        var num1=/^(?!、)(?!.*?、$)[a-zA-Z、\u4e00-\u9fa5]+$/;
        if(params=="true"){
            return num1.test(value);
        }
    },"输入的姓名只能由文字、英文以及“、”组成,且不能以“、”开头和结尾！");
    $.validator.addMethod("wordstyle1",function(value,element,params){
        var num1=/^(?!_)(?!.*?_$)[a-zA-Z0-9_]+$/;
        if(params=="true"){
            return num1.test(value);
        }
    },"输入的账号只能由数字、英文以及下划线组成,且不能以下划线开头和结尾！");
    $.validator.addMethod("checkcode",function(value,element){
        var pattern = new RegExp("[`~!@#$^&*()=|{} ':;,.<>/?~！@#￥……&*（）——|【】‘：”“'。？%+ 　\"\\\\]");
        var specialStr = "";
        for(var i=0;i<value.length;i++){
            specialStr += value.substr(i, 1).replace(pattern, '');
        }
        if( specialStr == value){
            return true;
        }
        return false;
    },"禁止输入特殊字符");
    $.validator.addMethod("host_phone",function(value,element,params){//传入参数1表示验证手机号码，传入2表示验证座机
        //规则验证方法，这个方法返回false这代表没有通过验证，返回true则表示通过验证
        var phone1=/^1[345789]\d{9}$/;
        var phone2=/^0\d{2,3}-\d{7,8}$/;
        if(params==1){
            return phone1.test(value);
        }else{
            return phone2.test(value);
        }
    },"电话号码必须11位");
    $("#f").validate({
        rules:{
            host_building:{
                required:true,
                digits:true,
                rangelength:[1,2]
            },
            host_unit:{
                required:true,
                digits:true,
                rangelength:[1,2]
            },
            host_housenumber:{
                required:true,
                digits:true,
                rangelength:[3,3]
            },
            host_name:{
                required:true,
                rangelength:[2,10],
                checkcode:true,
                wordstyle:"true"
            },
            host_phone:{
                required:true,
                host_phone:1
            },
            host_number:{
                required:true,
                digits:true,
                rangelength:[1,11]
            },
            host_create_admin_id:{
                required:true,
                digits:true,
                rangelength:[1,1]
            }
        },
        messages:{
            host_building:{
                required:"楼栋必须填写",
                digits:"必须是整数",
                rangelength:"长度为1至2位"
            },
            host_unit:{
                required:"单元必须填写",
                digits:"必须是整数",
                rangelength:"长度为1至2位"
            },
            host_housenumber:{
                required:"门牌号必须填写",
                digits:"必须是整数",
                rangelength:"长度为3位"
            },
            host_name:{
                required:"业主必须填写",
                rangelength:"长度为2~10位",
                checkcode:"请检查无效字符"
            },
            host_phone:{
                required:"手机号必须填写"
            },
            host_number:{
                required:"住户人数必须填写",
                digits:"必须是整数",
                rangelength:"长度为1"
            },
            host_create_admin_id:{
                required:"创建人编号必须填写",
                digits:"必须是整数",
                rangelength:"长度为1"
            }
        }
    });
</script>
</html>
